package com.jframework.module.usps.Services;


import java.util.Map;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;


import com.jframework.module.usps.USPSConstants;
import com.jframework.module.usps.beans.rates.RateV3Response;
import com.jframework.module.usps.beans.USPSBaseResponseObject;


public class USPSRateV3Service extends USPSBaseService 
{

    static Log log = LogFactory.getLog(USPSRateV3Service.class);
    
//    private RateV3Request rateV3Request = null;
    
    public USPSBaseResponseObject  doService(Map parameters) throws Exception 
    {
/*	RateV3Request rateV3Request = new RateV3Request(); 
	rateV3Request.setUSERID(userId);
	RateV3RequestPackage package1 = new RateV3RequestPackage();	
    	package1.setID("01");    	   
    	package1.setService("ALL");    
    	package1.setZipOrigination((String)parameters.get("uspsZIPOrigin"));
    	package1.setZipDestination((String)parameters.get("destinationZip"));
    	package1.setSize((String)parameters.get("uspsContainerSize"));
    	package1.setMachinable(new Boolean((String) parameters.get("uspsMachinable")));  	  
*/
  /*
      this.machinable			= new Boolean((String) getSettings().getValue("uspsMachinable"));
      this.package_Size			= (String) getSettings().getValue("uspsContainerSize");
      this.USPS_PackageUseDimensions = (String) getSettings().getValue("USPS_PackageUseDimensions");
      this.default_Length = (String) getSettings().getValue("UPS_packageDimensionsLength");
      this.default_Height = (String) getSettings().getValue("UPS_packageDimensionsHeight");
      this.default_Width = (String) getSettings().getValue("UPS_packageDimensionsWidth");
   */
	// Shipment Weight
	// Fixed this to use the packages from the new table, not the
	// getOrder().getWeight()

//	   double totalWeight = 0;
//	   if (getUser().getOrder().getOrderDeliveryCollection() != null
//				&& !getUser().getOrder().getOrderDeliveryCollection().isEmpty()) {
//			Iterator i = getUser().getOrder().getOrderShippingRules()
//					.iterator();
//			if (i.hasNext()) {
//				OrderShippingRule osr = (OrderShippingRule) i.next();
//				if (osr.getRuleType().equals("[package]"))
//					totalWeight += osr.getPkgWeight().doubleValue();
//			}
//	  }

/*	  package1.setPounds(new Integer(5));
	  package1.setOunces(new Double(3.2));
	  
	  rateV3Request.addPackage(package1);
*/	 
	//to make sure we got right API name
	this.setAPIName(USPSConstants.API_TYPE_RateV3);
	RateV3Response responseObject = (RateV3Response)this.makeUSPSCall(RateV3Response.class);
	
	return responseObject;
    }

 /*   public void initialize(Map settings) 
    {
     if (null != settings)
     {
	 super.initialize(settings);        
               //can be runtime supplied.    
     }   
    }*/
    
    
    

}
